﻿// See https://aka.ms/new-console-template for more information

using MongoDB.Driver;
using MongoDB2;

Console.WriteLine("Hello, World!");

var client = new MongoClient("mongodb://localhost:37017");
var database = client.GetDatabase("DemoDatabase");
var collection = database.GetCollection<Contact>("Contact");

var contact =
    new Contact { Name = "Contact 1", PhoneNumber = "+86 13800 138000" };

collection.InsertOne(contact);

var cursor = collection.FindSync(
    new FilterDefinitionBuilder<Contact>()
        .Where(p =>
            p.PhoneNumber.Contains("138")));
Console.WriteLine(cursor.First().Name);